﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace LabMS.Web.Post.BBS
{
    public partial class Section : Base.BasePage
    {
        public LabMS.Model.PostPlate ppInfo;
        public DataSet dsPlates;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int id = 0;

                if (string.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    WriteBackScript("alert('指定版块分区不存在');window.location.href='Index.aspx';");
                    return;
                }

                if (!int.TryParse(Request.QueryString["id"], out id))
                {
                    WriteBackScript("alert('指定版块分区不存在');window.location.href='Index.aspx';");
                    return;
                }

                ExtendBLL.PostPlate pp = new ExtendBLL.PostPlate();

                ppInfo = pp.GetModel(id);

                if (ppInfo == null)
                {
                    WriteBackScript("alert('指定版块分区不存在');window.location.href='Index.aspx';");
                    return;
                }

                dsPlates = pp.GetSubPlates(id, true);
            }
        }

        /// <summary>
        /// 写回脚本
        /// </summary>
        /// <param name="script">脚本内容</param>
        protected void WriteBackScript(string script)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
                Guid.NewGuid().ToString(), "<script type='text/javascript'>" + script + "</script>");
        }
    }
}
